package com.cq.androidtools.recycleview.table2

import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import android.widget.HorizontalScrollView


/**
 * 作者: CQ
 * 日期: 2021-08-24
 * 说明:
 */
class HorizontalScrollViewContent @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0,
) : HorizontalScrollView(context, attrs, defStyleAttr) {

    private var onScroll: (x: Int, y : Int) -> Unit = {x, y ->}

    fun setOnHorizontalScrollChangedListener(onScroll: (x: Int, y : Int) -> Unit = {x, y ->}) {
        this.onScroll = onScroll
    }

    override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
        super.onScrollChanged(l, t, oldl, oldt)
        onScroll(l, t)
    }

    override fun requestChildRectangleOnScreen(child: View?, rectangle: Rect?, immediate: Boolean): Boolean {
        return false
    }

}
